import java.util.*;

public class User {
    private String libraryNumber;
    private String password;
    private String username;
    private String emailAddress;
    private Integer phoneNumber;

    private static ArrayList<User> users = new ArrayList<User>();

    public static User authenticate(String libraryNumber, String password){
        for(User user : users){
            if(user.getLibraryNumber().equals(libraryNumber) && user.checkPassword(password))
                return user;

        }
        return null;
    }

    public User(String libraryNumber, String password, String username, String emailAddress, Integer phoneNumber){
        this.libraryNumber = libraryNumber;
        this.password = password;
        this.username = username;
        this.emailAddress = emailAddress;
        this.phoneNumber = phoneNumber;
        users.add(this);
    }

    public String getLibraryNumber() {
        return libraryNumber;
    }

    public String getName(){
        return username;
    }

    public String getEmailAddress(){
        return emailAddress;
    }

    public Integer getPhoneNumber(){
        return phoneNumber;
    }

    public boolean checkPassword(String pass){
        return password.equals(pass);
    }
}